2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3 * with this source distribution.
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6 * General Public License as published by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 * Public License for more details.
13 * You should have received a copy of the GNU General Public License along with this program; if not,
14 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 General Preferences. Currently responsible for:
19 - Logging enable/disable
20 - Message sending key (enter, return)
21 - Message tabs (create in tabs, organize tabs by group, sort tabs)
27 In the past, these various items were with specific plugins. While this provides a nice level of abstraction,
28 it also makes it much more difficult to ensure a consistent look/feel to the preferences.
31 #import <Adium/AIContentControllerProtocol.h>
32 #import <Adium/AIInterfaceControllerProtocol.h>
33 #import "ESGeneralPreferences.h"
34 #import "ESGeneralPreferencesPlugin.h"
35 #import <AIUtilities/AIDictionaryAdditions.h>
36 #import <AIUtilities/AISendingTextView.h>
37 #import <Adium/AIServiceIcons.h>
38 #import <Adium/AIStatusIcons.h>
41 #import "PTHotKeyCenter.h"
43 #define TAB_DEFAULT_PREFS @"TabDefaults"
45 #define SENDING_KEY_DEFAULT_PREFS @"SendingKeyDefaults"
47 #define CONFIRMATION_DEFAULT_PREFS @"ConfirmationDefaults"
49 @interface ESGeneralPreferencesPlugin (PRIVATE)
50 - (void)_configureSendingKeysForObject:(id)inObject;
53 @implementation ESGeneralPreferencesPlugin
58 [[adium preferenceController] registerDefaults:[NSDictionary dictionaryNamed:TAB_DEFAULT_PREFS
59 forClass:[self class]]
60 forGroup:PREF_GROUP_INTERFACE];
62 [[adium preferenceController] registerDefaults:[NSDictionary dictionaryNamed:SENDING_KEY_DEFAULT_PREFS
63 forClass:[self class]]
64 forGroup:PREF_GROUP_GENERAL];
66 [[adium preferenceController] registerDefaults:[NSDictionary dictionaryNamed:CONFIRMATION_DEFAULT_PREFS
67 forClass:[self class]]
68 forGroup:PREF_GROUP_CONFIRMATIONS];
70 //Install our preference view
71 preferences = [[ESGeneralPreferences preferencePaneForPlugin:self] retain];
73 [[adium preferenceController] registerPreferenceObserver:self forGroup:PREF_GROUP_GENERAL];
76 - (void)uninstallPlugin
81 - (void)hitHotKey:(PTHotKey *)hotKey
83 if (![NSApp isActive]) {
84 [NSApp activateIgnoringOtherApps:YES];
87 //Switch to the appropriate window, just like clicking the dock; this method will handle switching to a chat with unviewed content, for example.
88 [[adium interfaceController] handleReopenWithVisibleWindows:NO];
90 //Now ensure that all Adium windows are visible
94 - (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key object:(AIListObject *)object
95 preferenceDict:(NSDictionary *)prefDict firstTime:(BOOL)firstTime
97 if (firstTime || [key isEqualToString:KEY_GENERAL_HOTKEY]) {
99 //Unregister the old global hot key if it exists
100 [[PTHotKeyCenter sharedCenter] unregisterHotKey:globalHotKey];
101 [globalHotKey release]; globalHotKey = nil;
104 id plistRepresentation = [prefDict objectForKey:KEY_GENERAL_HOTKEY];
105 if (plistRepresentation) {
106 //Register a new one if we want one
107 globalHotKey = [[PTHotKey alloc] initWithIdentifier:KEY_GENERAL_HOTKEY
108 keyCombo:[[[PTKeyCombo alloc] initWithPlistRepresentation:plistRepresentation] autorelease]];
110 [globalHotKey setTarget:self];
111 [globalHotKey setAction:@selector(hitHotKey:)];
113 [[PTHotKeyCenter sharedCenter] registerHotKey:globalHotKey];